package com.sx.pipeline.arouth

import android.content.Context
import android.os.Bundle
import com.alibaba.android.arouter.facade.callback.NavCallback
import com.alibaba.android.arouter.facade.callback.NavigationCallback
import com.alibaba.android.arouter.launcher.ARouter
import com.sx.pipeline.app.config.IntentKey
import com.sx.pipeline.repos.http.res.AgreementVO
import com.sx.pipeline.repos.http.res.TerritoryVO
import com.sx.pipeline.repos.local.db.table.PipeFileBeanDO

/**
 * @Author: YY
 * @Date: 2022/1/20
 * @Describe: ARouter 路由跳转 统一接口
 */
class RouteManager {

    object Main {
        // 跳转主页
        fun intentToMain(context: Context, navCallback: NavigationCallback) {
            ARouter.getInstance().build(RoutePath.Main.MAIN).navigation(context, navCallback)
        }

        // 跳转搜索地址
        fun intentToSearchLocation() {
            ARouter.getInstance().build(RoutePath.Main.SEARCH_LOCATION).navigation()
        }

        fun intentToDistrictBorder(name: String? = null) {
            ARouter.getInstance().build(RoutePath.Main.DISTRICT_BORDER).with(
                Bundle().also {
                    it.putString(IntentKey.DATA, name)
                }).navigation()
        }

        //跳转学习中心
        fun intentToLearningCenter() {
            ARouter.getInstance().build(RoutePath.Main.LEARNING_CENTER).navigation()
        }
        //跳转广告宣传
        fun intentToAdvertising() {
            ARouter.getInstance().build(RoutePath.Main.ADVERTISING)
                .navigation()
        }
        //跳转广告宣传 商品列表
        fun intentToAdvertisingGoods(unitId:Int) {
            ARouter.getInstance().build(RoutePath.Main.ADVERTISING_GOODS)
                .withInt(IntentKey.ID,unitId)
                .navigation()
        }

        // 身份管理
        fun intentToIdentityManage() {
            ARouter.getInstance().build(RoutePath.Main.IDENTITY_MANAGE).navigation()
        }

        // 加入企业
        fun intentToJoinBusiness() {
            ARouter.getInstance().build(RoutePath.Main.JOIN_BUSINESS).navigation()
        }
    }

    object Login {

        fun intentToLogin(context:
                          Context, navCallback: NavCallback?) {
            ARouter.getInstance().build(RoutePath.Login.LOGIN_PATH).navigation(context, navCallback)
        }

        fun intentToBindPhone(openId: String, type: Int) {
            val bundle = Bundle()
            bundle.putString(IntentKey.DATA, openId)
            bundle.putInt(IntentKey.TYPE, type)
            ARouter.getInstance().build(RoutePath.Login.BIND_PHONE).with(bundle).navigation()
        }
    }

    object Register {
        // 选择 注册类型
        fun intentToRegSelectTypeID() {
            ARouter.getInstance().build(RoutePath.Register.REG_SELECT_TYPE_ID).navigation()
        }
        // 单位注册
        fun intentToRegUnit(identity: Int) {
            val bundle = Bundle()
            bundle.putInt(IntentKey.ID, identity)
            ARouter.getInstance().build(RoutePath.Register.REG_UNIT).with(bundle).navigation()
        }
        // 个人注册
        fun intentToRegPersonal(identity: Int) {
            val bundle = Bundle()
            bundle.putInt(IntentKey.ID, identity)
            ARouter.getInstance().build(RoutePath.Register.REG_PERSONAL).with(bundle).navigation()
        }
        // 协议
        fun intentToAgreement(agreement: AgreementVO) {
            ARouter.getInstance().build(RoutePath.Register.USER_AGREEMENT).with(Bundle().also {
                it.putSerializable(IntentKey.DATA, agreement)
            }).navigation()
        }
    }

    object ForgetPwd {
        // 修改密码
        fun intentToForgetPwd() {
            ARouter.getInstance().build(RoutePath.ForgetPwd.FORGET_PWD).navigation()
        }
    }

    object Message {
        // 消息中心
        fun intentToMessageCenter(noticeNum:Int) {
            ARouter.getInstance().build(RoutePath.Message.MESSAGE_CENTER)
                .withInt(IntentKey.DATA,noticeNum)
                .navigation()
        }

        // 消息列表
        fun intentToMessageList(code:Int,title:String,) {
            ARouter.getInstance().build(RoutePath.Message.MESSAGE_LIST)
                .withInt("code",code)
                .withString("title",title)
                .navigation()
        }
    }

    object Service{
        //跳转添加服务/编辑服务
        fun intentToServiceAdd(type:Int,id:Int) {
            ARouter.getInstance().build(RoutePath.Service.SERVICE_ADD)
                .withInt(IntentKey.TYPE,type)
                .withInt(IntentKey.ID,id)
                .navigation()
        }
        //服务列表
        fun intentToServiceList() {
            ARouter.getInstance().build(RoutePath.Service.SERVICE_LIST)
                .navigation()
        }
    }

    object Mine {
        // 任务发布
        fun intentToTaskReleaseAdd() {
            ARouter.getInstance().build(RoutePath.Mine.RELEASE_TASK_ADD).navigation()
        }
        // 任务发布详情
        fun intentToReleaseTaskDetail(taskId:Int) {
            ARouter.getInstance().build(RoutePath.Mine.RELEASE_TASK_DETAIL).withInt(IntentKey.ID,taskId).navigation()
        }

        // 参与的任务详情
        fun intentToParticipateTaskDetail(taskId:Int) {
            ARouter.getInstance().build(RoutePath.Mine.PARTICIPATE_TASK_DETAIL).withInt(IntentKey.ID,taskId).navigation()
        }

        // 任务发布-处理任务
        fun intentToTaskProcess(taskId:Int,hasGroup:String) {
            ARouter.getInstance().build(RoutePath.Mine.TASK_PROCESS).withInt(IntentKey.ID,taskId).withString(IntentKey.STATUS,hasGroup).navigation()
        }

        // 任务审批详情
        fun intentToTaskApproveDetail(taskId:Int) {
            ARouter.getInstance().build(RoutePath.Mine.ARRROVED_TASK_DETAIL).withInt(IntentKey.ID,taskId).navigation()
        }

        // 任务发布-申请延期
        fun intentToTaskPostpone(taskId:Int) {
            ARouter.getInstance().build(RoutePath.Mine.TASK_POSTPONE).withInt(IntentKey.ID,taskId).navigation()
        }

        //供应列表
        fun intentToProvideInfo(){
            ARouter.getInstance().build(RoutePath.Provide.PROVIDE_LIST).navigation()
        }

        //供应详情
        fun intentToProvideDetail(taskId:Int){
            ARouter.getInstance().build(RoutePath.Provide.PROVIDE_DETAIL).withInt(IntentKey.ID,taskId).navigation()

        }

        //询价列表
        fun intentTViewInquiry(orderId:Int){
            ARouter.getInstance().build(RoutePath.Mine.VIEW_INQUIRY_LIST).withInt(IntentKey.ID,orderId).navigation()
        }

        //报价列表
        fun intentViewQuoted(orderId:Int){
            ARouter.getInstance().build(RoutePath.Mine.VIEW_QUOTE_LIST).withInt(IntentKey.ID,orderId).navigation()
        }

        //我发布的任务列表
        fun intentToReleaseTaskList(){
            ARouter.getInstance().build(RoutePath.Mine.RELEASE_TASK_LIST).navigation()
        }

        //发布任务-立即评价
        fun intentToEvaluationNow(data: String){
            ARouter.getInstance().build(RoutePath.Mine.TASK_EVALUATE).withString(IntentKey.DATA,data).navigation()
        }

        //发布任务-立即评价
        fun intentToEvaluationList(orderId: Int){
            ARouter.getInstance().build(RoutePath.Mine.TASK_EVALUATE_LIST).withInt(IntentKey.ID,orderId).navigation()
        }

        //我参与的任务列表
        fun intentToParticipateTaskList(){
            ARouter.getInstance().build(RoutePath.Mine.PARTICIPATE_TASK_LIST).navigation()
        }

        //我审批的任务列表
        fun intentToApproveTaskList(){
            ARouter.getInstance().build(RoutePath.Mine.APPROVE_TASK_LIST).navigation()
        }

        // 运营单位 需求详情
        fun intentToOperatorNeedsDetail(needsId:Int) {
            ARouter.getInstance().build(RoutePath.Mine.OPERATOR_NEEDS_DETAIL).withInt(IntentKey.ID,needsId).navigation()
        }

        // 施工单位 发布需求
        fun intentToConstructionNeedsAdd() {
            ARouter.getInstance().build(RoutePath.Mine.CONSTRUCTION_NEEDS_ADD).navigation()
        }

        // 施工单位 我发布的需求
        fun intentToReleaseRequire() {
            ARouter.getInstance().build(RoutePath.Mine.RELEASE_REQUIREMENT_LIST).navigation()
        }

        // 施工单位 需求详情
        fun intentToConstructionNeedsDetail(needsId:Int) {
            ARouter.getInstance().build(RoutePath.Mine.CONSTRUCTION_NEEDS_DETAIL).withInt(IntentKey.ID,needsId).navigation()
        }

        // 施工单位 我参与的需求
        fun intentToParticipationNeeds() {
            ARouter.getInstance().build(RoutePath.Mine.PARTICIPATION_NEEDS).navigation()
        }

        // 施工单位 我参与的需求
        fun intenttoApprovalRequire() {
            ARouter.getInstance().build(RoutePath.Mine.APPROVE_NEEDS).navigation()
        }

        // 供应商 我发布的供应
        fun intentToReleaseSupply() {
            ARouter.getInstance().build(RoutePath.Mine.SUPPLY_TASK_LIST).navigation()
        }

        // 供应商 我审批的供应
        fun intentToApprovalSupply() {
            ARouter.getInstance().build(RoutePath.Mine.APPROVE_SUPPLY).navigation()
        }

        // 供应商 发布供应
        fun intentToReleaseSupplyAdd() {
            ARouter.getInstance().build(RoutePath.Mine.SUPPLY_ADD)
                .navigation()
        }
        // 供应商 供应详情
        fun intentToSupplyDetail(taskId:Int) {
            ARouter.getInstance().build(RoutePath.Mine.SUPPLY_DETAIL).withInt(IntentKey.ID,taskId).navigation()
        }

        // 供应商 审核供应详情
        fun intentToSupplyApprovalDetail(taskId:Int) {
            ARouter.getInstance().build(RoutePath.Mine.SUPPLY_APPROVAL_DETAIL).withInt(IntentKey.ID,taskId).navigation()
        }

        //供应商需求列表
        fun intentToSupplyNeedsList() {
            ARouter.getInstance().build(RoutePath.Mine.SUPPLIER_PARTICIPATION_NEEDS).navigation()
        }

        //跳转添加设备/编辑设备
        fun intentToDeviceAdd(type:Int,id:Int) {
            ARouter.getInstance().build(RoutePath.Mine.DEVICE_ADD)
                .withInt(IntentKey.TYPE,type)
                .withInt(IntentKey.ID,id)
                .navigation()
        }

        //跳转台账设备详情
        fun intentToDeviceDetail(id:Int,isedit:Boolean,isCall:Boolean) {
            ARouter.getInstance().build(RoutePath.Mine.DEVICE_DETAIL)
                .withInt(IntentKey.ID,id)
                .withBoolean(IntentKey.ISCALL,isCall)
                .withBoolean(IntentKey.ISEDIT,isedit)
                .navigation()
        }

        //跳转添加商品/编辑商品
        fun intentToGoodsAdd(type:Int,id:Int) {
            ARouter.getInstance().build(RoutePath.Mine.COMMODITY_ADD)
                .withInt(IntentKey.TYPE,type)
                .withInt(IntentKey.ID,id)
                .navigation()
        }

        //跳转台账设备详情
        fun intentToGoodsDetail(id:Int,isedit:Int) {
            ARouter.getInstance().build(RoutePath.Mine.COMMODITY_DETAIL)
                .withInt(IntentKey.ID,id)
                .withInt(IntentKey.ISEDIT,isedit)
                .navigation()
        }

        // 运营商-发布需求
        fun intentToOperatorNeedsAdd() {
            ARouter.getInstance().build(RoutePath.Mine.OPERATOR_ADD_NEEDS).navigation()
        }

        //人员审核
        fun intentToOperatorExamineManager(){
            ARouter.getInstance().build(RoutePath.Mine.OPERATOR_EXAMINE_MANAGER).navigation()
        }

        //人员审核信息
        fun intentToExaminePerson(id: String,option: Boolean){
            ARouter.getInstance().build(RoutePath.Mine.EXAMINE_PERSON_INFO)
                .withString("id",id)
                .withBoolean("option",option)
                .navigation()
        }

        //审核提交记录
        fun intentToExamineRecord(){
            ARouter.getInstance().build(RoutePath.Mine.OPERATOR_EXAMINE_RECORD).navigation()
        }
    }


    object Territory {

        fun intentToTerritoryPage(index: Int = 0) {
            ARouter.getInstance().build(RoutePath.Territory.TERRITORY_PAGE).with(Bundle().also {
                it.putInt(IntentKey.TYPE, index)
            }).navigation()
        }

        fun intentToTerritoryDetails(type: Int, territoryVO: TerritoryVO) {
            ARouter.getInstance().build(RoutePath.Territory.TERRITORY_DETAILS)
                .with(Bundle().also {
                    it.putSerializable(IntentKey.DATA, territoryVO)
                    it.putInt(IntentKey.TYPE, type)
                }).navigation()
        }
    }

    object LinePipe {

        fun intentToLinePipeFile() {
            ARouter.getInstance().build(RoutePath.LinePipe.LINE_PIPE_FILE).navigation()
        }

        fun intentToLinePipePage() {
            ARouter.getInstance().build(RoutePath.LinePipe.LINE_PIPE_PAGE).navigation()
        }

        fun intentToLinePipeDetails(type: Int, territoryVO: PipeFileBeanDO) {
            ARouter.getInstance().build(RoutePath.LinePipe.LINE_PIPE_DETAILS)
                .with(Bundle().also {
                    it.putSerializable(IntentKey.DATA, territoryVO)
                    it.putInt(IntentKey.TYPE, type)
                }).navigation()
        }
    }

}